﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

/// <summary>
/// Summary description for SelectionModel
/// </summary>
[Serializable]
public class SelectionModel
{
    public  SelectionModel()
    {
        this.SelectedItems = new List<SelectionItem>();
    }

    public List<SelectionItem> SelectedItems { get; set; }

    public List<FoodValueDisplay> GetCalculatedFoodValues()
    {
        List<FoodValueDisplay> lst = new List<FoodValueDisplay>();
        FoodValueDisplay dispTotal = new FoodValueDisplay() { Name = "Total", BengaliName = "Total" };
        foreach (SelectionItem item in this.SelectedItems)
        {
            FoodValue val = Manager.GetFoodValue(item.FoodCode);
            FoodValueDisplay disp = new FoodValueDisplay(val, item.Amount);
            dispTotal.Amount += disp.Amount;
            dispTotal.BCarotene += disp.BCarotene;
            dispTotal.Calccium += disp.Calccium;
            dispTotal.Carbohydrate += disp.Carbohydrate;
            dispTotal.Energy += disp.Energy;
            dispTotal.Fat += disp.Fat;
            dispTotal.Fibre += disp.Fibre;
            dispTotal.Iron += disp.Iron;
            dispTotal.Moisture += disp.Moisture;
            dispTotal.Protein += disp.Protein;
            dispTotal.Refuse += disp.Refuse;
            dispTotal.Retinol += disp.Retinol;
            dispTotal.RetinolEquiv += disp.RetinolEquiv;
            dispTotal.Riboflavin += disp.Riboflavin;
            dispTotal.Thiamin += disp.Thiamin;
            dispTotal.TotalMineral += disp.TotalMineral;
            dispTotal.VitaC += disp.VitaC;

            lst.Add(disp);
        }
        lst.Add(dispTotal);
        return lst;
    }
}